// router.js
import {RouterMount,createRouter} from 'uni-simple-router';
import queue from '@/common/queue'
const router = createRouter({
    platform: process.env.VUE_APP_PLATFORM,  
    routes: [...ROUTES]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
	// console.log('!queue.isEmpty(from.query.channelCode)',!queue.isEmpty(from.query.channelCode))
	console.log('to55',to)
	console.log('from',from)
	let pages = getCurrentPages() //获取当前页面栈的信息
	let queryToData = to.query
	let queryFromData = from.query
	if(queue.isEmpty(queryToData.channelCode) && !queue.isEmpty(queryFromData.channelCode)){
		queryToData.channelCode = queryFromData.channelCode
		next({path:to.path, query:queryToData});
	}else{
		next();
	}
	
});
// 全局路由后置守卫
router.afterEach((to, from) => {
    console.log('跳转结束')
})
 
export {
    router,
    RouterMount
}